// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import G from './global'
import axios from 'axios'
import qs from 'qs'
import Utils from './utils'
import Store from './store'
axios.defaults.baseURL = 'http://table.lovecampus.cn/page'
Vue.prototype.$axios = axios
Vue.config.productionTip = false

Vue.use(ElementUI)
Vue.use(G)
Vue.use(Store)

Vue.component('v-handle', {
  template: '<div class="handle" v-show="handle.show"><span class="close" v-on:click="del_item" title="删除"></span><span class="clone" v-on:click="copy_item" title="复制"></span><span class="toup" v-on:click="up_item" title="上移" v-show="handle.up"></span><span class="todown" v-on:click="down_item" title="下移" v-show="handle.down"></span></div>',
  props: ['handle'],
  data:function(){
    return { 
    }
  },
  methods: {
    del_item: function () {
      this.$confirm('确认删除？')
          .then(_ => {
           Utils.item_remove(this.$pageView.formItems, this.$parent.$attrs.id)
          })
          .catch(_ => {});
    },
    copy_item: function () {
      Utils.item_copy(this.$pageView.formItems, this.$parent.$attrs.id)
    },
    up_item: function () {
      Utils.item_up(this.$pageView.formItems, this.$parent.$attrs.id)
    },
    down_item: function () {
      Utils.item_down(this.$pageView.formItems, this.$parent.$attrs.id)
    }
  }
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: {
    App
  },
  template: '<App/>'
})
